home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_xfig.idb / usr / freeware / src / xfig / transfig.3.1.2 / fig2dev / object.h.z / object.h
Encoding:
C/C++ Source or Header  |  1997-09-09  |  7.5 KB  |  284 lines

  1. /*
  2.  * TransFig: Facility for Translating Fig code
  3.  * Copyright (c) 1985 Supoj Sutantavibul
  4.  * Copyright (c) 1991 Micah Beck
  5.  *
  6.  * THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  7.  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  8.  * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  9.  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  10.  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  11.  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  12.  * PERFORMANCE OF THIS SOFTWARE.
  13.  *
  14.  * The X Consortium, and any party obtaining a copy of these files from
  15.  * the X Consortium, directly or indirectly, is granted, free of charge, a
  16.  * full and unrestricted irrevocable, world-wide, paid up, royalty-free,
  17.  * nonexclusive right and license to deal in this software and
  18.  * documentation files (the "Software"), including without limitation the
  19.  * rights to use, copy, modify, merge, publish, distribute, sublicense,
  20.  * and/or sell copies of the Software, and to permit persons who receive
  21.  * copies from any such party to do so, with the only requirement being
  22.  * that this copyright notice remain intact.  This license includes without
  23.  * limitation a license to do the foregoing actions under any patents of
  24.  * the party supplying this software to the X Consortium.
  25.  */
  26.  
  27. #define    BLACK_COLOR    0
  28. #define    WHITE_COLOR    7
  29.  
  30. #define        DEFAULT                (-1)
  31.  
  32. typedef        struct f_point {
  33.             int            x, y;
  34.             struct f_point        *next;
  35.             }
  36.         F_point;
  37.  
  38. typedef        struct f_pos {
  39.             int            x, y;
  40.             }
  41.         F_pos;
  42.  
  43. typedef        struct f_arrow {
  44.             int            type;
  45.             int            style;
  46.             double            thickness;
  47.             double            wid;
  48.             double            ht;
  49.             }
  50.         F_arrow;
  51.  
  52. typedef        struct f_ellipse {
  53.             int            type;
  54. #define                    T_ELLIPSE_BY_RAD    1
  55. #define                    T_ELLIPSE_BY_DIA    2
  56. #define                    T_CIRCLE_BY_RAD        3
  57. #define                    T_CIRCLE_BY_DIA        4
  58.             int            style;
  59.             int            thickness;
  60.             int            pen_color;
  61.             int            fill_color;
  62.             int            depth;
  63.             int            pen;
  64.             int            fill_style;
  65.             double            style_val;
  66.             int            direction;
  67.             double            angle;
  68. #define                           UNFILLED    -1
  69. #define                           WHITE_FILL    0
  70. #define                           BLACK_FILL    20
  71.             struct f_pos        center;
  72.             struct f_pos        radiuses;
  73.             struct f_pos        start;
  74.             struct f_pos        end;
  75.             struct f_ellipse    *next;
  76.             }
  77.         F_ellipse;
  78.  
  79. typedef        struct f_arc {
  80.             int            type;
  81. #define                    T_OPEN_ARC        1
  82. #define                    T_PIE_WEDGE_ARC        2
  83.             int            style;
  84.             int            thickness;
  85.             int            pen_color;
  86.             int            fill_color;
  87.             int            depth;
  88.             int            pen;
  89.             int            fill_style;
  90.             double            style_val;
  91.             struct f_arrow        *for_arrow;
  92.             struct f_arrow        *back_arrow;
  93.             int            cap_style;
  94. /* IMPORTANT: everything above this point must be in the same order 
  95.           for ARC, LINE and SPLINE (LINE has join_style following cap_style */
  96.             int            direction;
  97.             struct {double x, y;}    center;
  98.             struct f_pos        point[3];
  99.             struct f_arc        *next;
  100.             }
  101.         F_arc;
  102.  
  103. typedef        struct f_line {
  104.             int            type;
  105. #define                    T_POLYLINE    1
  106. #define                    T_BOX        2
  107. #define                    T_POLYGON    3
  108. #define                                    T_ARC_BOX       4
  109. #define                                    T_PIC_BOX       5 
  110.  
  111.             int            style;
  112.             int            thickness;
  113.             int            pen_color;
  114.             int            fill_color;
  115.             int            depth;
  116.             int            pen;
  117.              int            fill_style;
  118.             double            style_val;
  119.             struct f_arrow        *for_arrow;
  120.             struct f_arrow        *back_arrow;
  121.             int            cap_style;
  122. /* IMPORTANT: everything above this point must be in the same order 
  123.           for ARC, LINE and SPLINE (LINE has join_style following cap_style */
  124.              int            join_style;
  125.             int            radius;    /* for T_ARC_BOX */
  126.             struct f_point        *points;
  127.                 struct f_pic           *pic;
  128.             struct f_line        *next;
  129.             }
  130.         F_line;
  131.  
  132. typedef struct f_pic {
  133.     int            subtype;
  134. #define    P_EPS    0    /* EPS picture type */
  135. #define    P_XBM    1    /* X11 bitmap picture type */
  136. #define    P_XPM    2    /* X11 pixmap (XPM) picture type */
  137. #define    P_GIF    3    /* GIF picture type */
  138. #define    P_JPEG    4    /* JPEG picture type */
  139.     char            file[256];
  140.     int             flipped;
  141.     unsigned char  *bitmap;
  142.     unsigned char   cmap[3][MAXCOLORMAPSIZE]; /* for color files */
  143.     int            numcols;        /* number of colors in cmap */
  144.     float        hw_ratio;
  145.     struct f_pos    bit_size;
  146.     int             pix_rotation, pix_width, pix_height, pix_flipped;
  147. }
  148.         F_pic;
  149.  
  150. extern char EMPTY_PIC[];
  151.  
  152. typedef        struct f_text {
  153.             int            type;
  154. #define                    T_LEFT_JUSTIFIED    0
  155. #define                    T_CENTER_JUSTIFIED    1
  156. #define                    T_RIGHT_JUSTIFIED    2
  157.             int            font;
  158. #define                    DEFAULT_FONT        0
  159. #define                    ROMAN_FONT        1
  160. #define                    BOLD_FONT        2
  161. #define                    ITALIC_FONT        3
  162. #define                    MODERN_FONT        4
  163. #define                    TYPEWRITER_FONT        5
  164. #define                    MAX_FONT        5
  165.             double            size;    /* point size */
  166.             int            color;
  167.             int            depth;
  168.             double            angle;    /* in radian */
  169.             int            flags;
  170. #define                    RIGID_TEXT    1    
  171. #define                    SPECIAL_TEXT    2
  172. #define                    PSFONT_TEXT    4
  173.             double            height;    /* pixels */
  174.             double            length;    /* pixels */
  175.             int            base_x;
  176.             int            base_y;
  177.             int            pen;
  178.             char            *cstring;
  179.             struct f_text        *next;
  180.             }
  181.         F_text;
  182.  
  183. #define MAX_PSFONT    34
  184. #define MAXFONT(T) (psfont_text(T) ? MAX_PSFONT : MAX_FONT)
  185.  
  186. #define        rigid_text(t) \
  187.             (t->flags == DEFAULT \
  188.                 || (t->flags & RIGID_TEXT))
  189.  
  190. #define        special_text(t) \
  191.             ((t->flags != DEFAULT \
  192.                 && (t->flags & SPECIAL_TEXT)))
  193.  
  194. #define        psfont_text(t) \
  195.             (t->flags != DEFAULT \
  196.                 && (t->flags & PSFONT_TEXT))
  197.  
  198. typedef        struct f_control {
  199.             double            lx, ly, rx, ry;
  200.             struct f_control    *next;
  201.             }
  202.         F_control;
  203.  
  204. #define        int_spline(s)        (s->type & 0x2)
  205. #define        normal_spline(s)    (!(s->type & 0x2))
  206. #define        closed_spline(s)    (s->type & 0x1)
  207. #define        open_spline(s)        (!(s->type & 0x1))
  208.  
  209. typedef        struct f_spline {
  210.             int            type;
  211. #define                    T_OPEN_NORMAL        0
  212. #define                    T_CLOSED_NORMAL        1
  213. #define                    T_OPEN_INTERPOLATED    2
  214. #define                    T_CLOSED_INTERPOLATED    3
  215.             int            style;
  216.             int            thickness;
  217.             int            pen_color;
  218.             int            fill_color;
  219.             int            depth;
  220.             int            pen;
  221.             int            fill_style;
  222.             double            style_val;
  223.             struct f_arrow        *for_arrow;
  224.             struct f_arrow        *back_arrow;
  225.             int            cap_style;
  226. /* IMPORTANT: everything above this point must be in the same order 
  227.           for ARC, LINE and SPLINE (LINE has join_style following cap_style */
  228.             /*
  229.             For T_OPEN_NORMAL and T_CLOSED_NORMAL points
  230.             are control points while they are knots for
  231.             T_OPEN_INTERPOLATED and T_CLOSED_INTERPOLTED
  232.             whose control points are stored in controls.
  233.             */
  234.             struct f_point        *points;
  235.             struct f_control    *controls;
  236.             struct f_spline        *next;
  237.             }
  238.         F_spline;
  239.  
  240. typedef        struct f_compound {
  241.             struct f_pos        nwcorner;
  242.             struct f_pos        secorner;
  243.             struct f_line        *lines;
  244.             struct f_ellipse    *ellipses;
  245.             struct f_spline        *splines;
  246.             struct f_text        *texts;
  247.             struct f_arc        *arcs;
  248.             struct f_compound    *compounds;
  249.             struct f_compound    *next;
  250.             }
  251.         F_compound;
  252.  
  253. #define        ARROW_SIZE        sizeof(struct f_arrow)
  254. #define        POINT_SIZE        sizeof(struct f_point)
  255. #define        CONTROL_SIZE        sizeof(struct f_control)
  256. #define        ELLOBJ_SIZE        sizeof(struct f_ellipse)
  257. #define        ARCOBJ_SIZE        sizeof(struct f_arc)
  258. #define        LINOBJ_SIZE        sizeof(struct f_line)
  259. #define        PIC_SIZE        sizeof(struct f_pic)
  260. #define        TEXOBJ_SIZE        sizeof(struct f_text)
  261. #define        SPLOBJ_SIZE        sizeof(struct f_spline)
  262. #define        COMOBJ_SIZE        sizeof(struct f_compound)
  263.  
  264. /**********************  object codes  **********************/
  265.  
  266. #define        O_COLOR_DEF        0
  267. #define        O_ELLIPSE        1
  268. #define        O_POLYLINE        2
  269. #define        O_SPLINE        3
  270. #define        O_TEXT            4
  271. #define        O_ARC            5
  272. #define        O_COMPOUND        6
  273. #define        O_END_COMPOUND        (-O_COMPOUND)
  274. #define        O_ALL_OBJECT        99
  275.  
  276. /************  object styles (except for f_text)  ************/
  277.  
  278. #define        SOLID_LINE        0
  279. #define        DASH_LINE        1
  280. #define        DOTTED_LINE        2
  281.  
  282. #define        CLOSED_PATH        0
  283. #define        OPEN_PATH        1
  284.